//
//  AddressInfoSelectCell.m
//  BonweBuy
//
//  Created by liuxin on 2020/2/26.
//  Copyright © 2020 liuxin. All rights reserved.
//

#import "AddressInfoSelectCell.h"


@interface AddressInfoSelectCell()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@end

@implementation AddressInfoSelectCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    UILabel *titleLabel = [UILabel initWithTextColor:[UIColor blackColor] fontStr:UIPFThinFont(15)];
    [self.contentView addSubview:titleLabel];
    [titleLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.left.equalTo(self.contentView.mas_left).offset(kAppWidth_Mini(40));
        make.width.mas_equalTo(kAppWidth_Mini(200));
    }];
    self.titleLabel = titleLabel;
    
    UILabel *detailLabel = [UILabel initWithTextColor:[UIColor blackColor] fontStr:UIPFThinFont(15)];
    detailLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:detailLabel];
    [detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(kAppWidth_6(85));
        make.right.mas_equalTo(kAppWidth_6(-25));;
    }];
    self.detailLabel  = detailLabel;
}

-(void)setDataModel:(EditAddressModel *)dataModel{
    _dataModel = dataModel;
    self.titleLabel.text = _dataModel.title;
    NSString *content = [_dataModel.dataModel valueForKey:_dataModel.key];
    if (content.length > 0) {
        self.detailLabel.textColor = [UIColor blackColor];
        self.detailLabel.text = content;
    }else{
        self.detailLabel.text = _dataModel.placeHolder;
        self.detailLabel.textColor = [UIColor lightGrayColor];
    }
}

@end
